package com.huluobo.a2109kotlinshopping.home

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.a2109kotlinshopping.R
import com.huluobo.a2109kotlinshopping.utils.ImageUtils

/**
 *  Created by LC on 2024/1/11.
 *  构造方法:
 *  在kotlin中,一个类后面加上小括号就代表是它的构造方法
 *   HomeGoodsListAdapter(homeGoodsList: MutableList<HomeGoodsBean>)就是当前adapter的构造方法
 *   BaseQuickAdapter<HomeGoodsBean, BaseViewHolder>(R.layout.item_home_goods_list, homeGoodsList)
 *   就是被继承的父类的构造方法
 */
class HomeGoodsListAdapter(homeGoodsList: MutableList<HomeGoodsBean>) :
    BaseQuickAdapter<HomeGoodsBean, BaseViewHolder>(R.layout.item_home_goods_list, homeGoodsList) {
    override fun convert(helper: BaseViewHolder, item: HomeGoodsBean) {
        helper.setText(R.id.home_item_tv_goods_desc, item.goods_desc)//商品名称
        helper.setText(R.id.home_item_tv_goods_price, "价格:￥${item.goods_default_price}.00元")
//        Glide.with(context).load(item.goods_default_icon).into(helper.getView(R.id.home_item_iv_goods_icon))//设置商品图片
        ImageUtils.loadImage(context, item.goods_default_icon, helper.getView(R.id.home_item_iv_goods_icon))
    }
}